package com.gjy.redis.util.struct;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-10-14 15:33:24
 */
public class RedisConnection {

    private static final JedisPool jedisPool;

    static {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(20);
        config.setMaxIdle(10);
        config.setMinIdle(5);
        config.setTestOnBorrow(true);

        jedisPool = new JedisPool(config, "117.72.102.215", 9330, 2000);
    }

    public static Jedis getJedis() {
        return jedisPool.getResource();
    }

    public static void close() {
        if (jedisPool != null) {
            jedisPool.close();
        }
    }

}
